Add trackpad pinch-to-zoom gesture to the comic viewer - #530
Merged
Conversation
Enable the macOS and other Qt-supported trackpad pinch gesture to zoom continuously within the existing 30% to 500% bounds. Keep the cursor anchor stationary in single-page mode and preserve the existing viewport anchor in continuous-scroll mode. Show a compact translucent HUD in the bottom-right corner with the live zoom percentage while the gesture is active. The existing centered notification remains in use for keyboard zoom shortcuts. Relates to YACReader#435
luisangelsm
force-pushed
the
pinch-to-zoom
branch
from
August 7, 2026 17:30
0ea29dd to
970fda6
Compare
Member
|
Thank you, and sorry for taking me so long to review this. I added some improvements and I removed the setting, I don't think a setting is needed for this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #435.
What this adds
Native trackpad pinch-to-zoom in the comic viewer:
Cmd +/Cmd -) driven by the trackpad pinch gesture.Cmd +/Cmd -zoom.How it works
Viewernow grabsQt::PinchGesturein its constructor and overridesevent()to dispatchQEvent::Gestureto a newgestureEvent(QGestureEvent *).Qt::GestureStarted, then onQt::GestureUpdatedappliesbaselineZoom * pinch->totalScaleFactor()clamped to[30, 500], resizes the content, and adjusts the horizontal/vertical scroll bars to keep the anchor stationary.QLabelchild of the viewer, rendered as Qt rich text to keep the "%" text reliably white over the translucent background regardless of palette cascade. It shows onGestureStartedand hides onGestureFinished/GestureCanceled.PINCH_TO_ZOOM_ENABLEDin the existingQSettingsfile, exposed viaConfiguration::getPinchToZoomEnabled()/setPinchToZoomEnabled(), and checked on each gesture event so toggling in Preferences takes effect immediately.Cross-platform
No
#ifdef Q_OS_MACOSis needed.QPinchGestureis handled natively by Qt on macOS (trackpad) and Windows (touch), and is a no-op on platforms that do not deliver pinch events, so the feature is additive and does not regress existing behavior on Linux or on systems without a touch surface.Tested
Cmd +/Cmd -shortcuts and their HUD still work, two-finger scroll and the magnifying glass still work, the Zoom mode checkbox enables/disables the gesture at runtime.clang-formatpasses on the modified files.Both Qt 5 and Qt 6 code paths should compile (
QPinchGestureandQGestureEventare available in both), though I have only been able to test Qt 6 locally.